<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://amc.af.mil/portal-el" prefix="portal" %>
<%@ taglib uri="http://amc.af.mil/radtaglibrary" prefix="rad" %>
<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html-el" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
    <title>Index of ROS Packages</title>
</head>

<body>
<rad:useBean id="adpeAccountViewHelper"/>
<rad:useBean id="rosViewHelper"/>

<div id="portal-left-bar">
    <jsp:include page="../navigation/navigationMenu.jsp"/>
</div>

<div id="portal-content">
    <portal:box title="ROS/Waiver Information" style="width: 800px;">
        <portal:subSection title="Select ADPE Account">
            <p>
                <html:form method="get" action="ros/changeAccount.do">
                    <label for="adpeAccountId">ADPE Account</label>
                    <html:select property="adpeAccountId" value="${requestScope.adpeAccountId}">
                        <html:optionsCollection name="adpeAccountViewHelper"
                                                property="adpeAccountsByAccount"
                                                value="id"
                                                label="name"/>
                    </html:select>
                    <html:submit value="Change Account"/>
                </html:form>
            </p>
            <c:choose>
                <c:when test="${sessionScope.adpeAccount eq -1}">
                    <c:set var="rosList" value="${rosViewHelper.all}"/>
                </c:when>
                <c:otherwise>
                    <%--<rad:setProperty bean="rosViewHelper" name="adpeAccountId" value="${requestScope.accountId}" />--%>
                    <c:set var="rosList" value="${rosViewHelper.allByAccount}"/>
                </c:otherwise>
            </c:choose>
        </portal:subSection>
        <portal:subSection title="Package Listing">
            <display:table name="rosViewHelper.allByAccount"
                           id="ros"
                           style="width:100%">
                <%--<display:column property="name" title="ROS Package"/>--%>
                <display:column property="trackingNumber" title="LRS Tracking ID"/>
                <display:column property="type" title="Package Type"/>
                <display:column title="Status">
                    <c:out value="${ros.status.description}"/>
                </display:column>
                <display:column property="initDate" title="Open Date"/>
                <display:column title="Actions" style="text-align:center;">
                    <c:choose>
                        <c:when test="${ros.status.ordinal eq 5}">
                            <html:link href="ros/viewPackage.do?rosPackageId=${ros.id}">View</html:link>
                        </c:when>
                        <c:otherwise>
                            <html:link href="javascript:confirmCloseRosPackage(${ros.id}, '${ros.name}');">
                                Close</html:link>
                            <html:link href="javascript:confirmDeleteRosPackage(${ros.id}, '${ros.name}');">
                                Delete</html:link>
                            <html:link href="ros/viewEdit.do?rosPackageId=${ros.id}">Edit</html:link>
                        </c:otherwise>
                    </c:choose>

                </display:column>
            </display:table>
        </portal:subSection>
    </portal:box>
</div>

</body>
</html>